home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / include / X11 / XprintUtil / xprintutil.h
C/C++ Source or Header  |  2006-04-12  |  10KB  |  220 lines

  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. #ifndef XPRINTUTIL_H
  3. #define XPRINTUTIL_H 1
  4. /******************************************************************************
  5.  ******************************************************************************
  6.  **
  7.  ** (c) Copyright 2001-2004 Roland Mainz <roland.mainz@nrubsig.org>
  8.  ** 
  9.  ** Permission is hereby granted, free of charge, to any person obtaining a copy
  10.  ** of this software and associated documentation files (the "Software"), to deal
  11.  ** in the Software without restriction, including without limitation the rights
  12.  ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13.  ** copies of the Software, and to permit persons to whom the Software is
  14.  ** furnished to do so, subject to the following conditions:
  15.  **
  16.  ** The above copyright notice and this permission notice shall be included in
  17.  ** all copies or substantial portions of the Software.
  18.  **
  19.  ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20.  ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21.  ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
  22.  ** COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  23.  ** IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  24.  ** CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  25.  **
  26.  ** Except as contained in this notice, the names of the copyright holders shall
  27.  ** not be used in advertising or otherwise to promote the sale, use or other
  28.  ** dealings in this Software without prior written authorization from said
  29.  ** copyright holders.
  30.  **
  31.  ******************************************************************************
  32.  *****************************************************************************/
  33.  
  34.  
  35. /* Force ANSI C prototypes from X11 headers */
  36. #ifndef FUNCPROTO 
  37. #define FUNCPROTO 15
  38. #endif /* !FUNCPROTO */
  39.  
  40. #include <X11/Xlibint.h>
  41. #include <X11/extensions/Print.h>
  42. #include <X11/Intrinsic.h>
  43.  
  44. /* I don't know how to make this "better" yet... ;-( */
  45. #ifdef USE_MOZILLA_TYPES
  46. #include <prtypes.h>
  47. #include <prmem.h>
  48. #include <prthread.h>
  49. #define XPU_USE_NSPR 1
  50. /*
  51.  * Disabled for now - Threaded codepath does not work properly always.
  52.  * See bug 134570 ("Print-to-file not working with threaded XprintUtil")
  53.  * #define XPU_USE_THREADS 1
  54.  */
  55. #endif /* USE_MOZILLA_TYPES */
  56.  
  57. #ifdef DEBUG
  58. /* trace function calls */
  59. #define XPU_TRACE(EX)  (puts(#EX),EX)
  60. /* trace function calls in child */
  61. #define XPU_TRACE_CHILD(EX)  (puts("child: " #EX),EX)
  62. /* execute function EX only in debug mode */
  63. #define XPU_DEBUG_ONLY(EX)  (EX)
  64. #else
  65. #define XPU_TRACE(EX) (EX)
  66. #define XPU_TRACE_CHILD(EX) (EX)
  67. #define XPU_DEBUG_ONLY(EX)
  68. #endif /* DEBUG */
  69.  
  70. /* debug/logging: replace NULLptrs with "<NULL>" string */
  71. #define XPU_NULLXSTR(s) (((s)!=NULL)?(s):("<NULL>"))
  72.  
  73. /*
  74.  * Struct for XpuGetMediumSourceSizeList(), XpuFreeMediumSourceSizeList(),
  75.  * XpuSetDocMediumSourceSize(), XpuSetPageMediumSourceSize(),
  76.  * XpuFindMediumSourceSizeBy*()
  77.  */
  78. typedef struct {
  79.   const char *tray_name;
  80.   const char *medium_name;
  81.   int         mbool;
  82.   float       ma1; 
  83.   float       ma2; 
  84.   float       ma3; 
  85.   float       ma4;
  86. } XpuMediumSourceSizeRec, *XpuMediumSourceSizeList;
  87.  
  88. /*
  89.  * Struct for XpuGetResolutionList(), XpuFreeResolutionList(),
  90.  * XpuGetResolution(), XpuSetPageResolution(), XpuSetDocResolution(),
  91.  * XpuFindResolution()
  92.  */
  93. typedef struct {
  94.   long dpi;
  95.   /* ToDo: Support for Xdpi != Ydpi */
  96. } XpuResolutionRec, *XpuResolutionList;
  97.  
  98. /*
  99.  * Struct for XpuGetOrientationList(), XpuFreeOrientationList(),
  100.  * XpuFindOrientationBy*(), XpuSetPageResolution(), 
  101.  * XpuSetDocOrientation()
  102.  */
  103. typedef struct {
  104.   const char *orientation;
  105. } XpuOrientationRec, *XpuOrientationList;
  106.  
  107. /*
  108.  * Struct for XpuGetPlexList(), XpuFreePlexList(), XpuFindPlexBy*(),
  109.  * XpuSetDocPlex(), XpuSetPagePlex()
  110.  */
  111. typedef struct {
  112.   const char *plex;
  113. } XpuPlexRec, *XpuPlexList;
  114.  
  115.  
  116. /* XPUATTRIBUTESUPPORTED_*:
  117.  * Flags which indicate whether it is allowed to set/change a specific attribute
  118.  */
  119. typedef long XpuSupportedFlags;
  120. /* Job attributes */
  121. #define XPUATTRIBUTESUPPORTED_JOB_NAME                     (1L<<0)
  122. #define XPUATTRIBUTESUPPORTED_JOB_OWNER                    (1L<<1)
  123. #define XPUATTRIBUTESUPPORTED_NOTIFICATION_PROFILE         (1L<<2)
  124. /* Document/Page attributes */
  125. #define XPUATTRIBUTESUPPORTED_COPY_COUNT                   (1L<<3)
  126. #define XPUATTRIBUTESUPPORTED_DOCUMENT_FORMAT              (1L<<4)
  127. #define XPUATTRIBUTESUPPORTED_CONTENT_ORIENTATION          (1L<<5)
  128. #define XPUATTRIBUTESUPPORTED_DEFAULT_PRINTER_RESOLUTION   (1L<<6)
  129. #define XPUATTRIBUTESUPPORTED_DEFAULT_INPUT_TRAY           (1L<<7)
  130. #define XPUATTRIBUTESUPPORTED_DEFAULT_MEDIUM               (1L<<8)
  131. #define XPUATTRIBUTESUPPORTED_PLEX                         (1L<<9)
  132.  
  133. /* prototypes */
  134. _XFUNCPROTOBEGIN
  135.  
  136. int XpuCheckExtension( Display *pdpy );
  137.  
  138. /* Create/destroy connection to printer */
  139. int XpuGetPrinter( const char *printername, Display **pdpyptr, XPContext *pcontextptr );
  140. void XpuClosePrinterDisplay(Display *pdpy, XPContext pcontext);
  141.  
  142. /* Misc. functions */
  143. void XpuSetOneAttribute( Display *pdpy, XPContext pcontext, 
  144.                          XPAttributes type, const char *attribute_name, const char *value, XPAttrReplacement replacement_rule );
  145. void XpuSetOneLongAttribute( Display *pdpy, XPContext pcontext, 
  146.                          XPAttributes type, const char *attribute_name, long value, XPAttrReplacement replacement_rule );
  147. int XpuCheckSupported( Display *pdpy, XPContext pcontext, XPAttributes type, const char *attribute_name, const char *query );
  148. int XpuSetJobTitle( Display *pdpy, XPContext pcontext, const char *title );
  149. int XpuGetOneLongAttribute( Display *pdpy, XPContext pcontext, XPAttributes type, const char *attribute_name, long *result );
  150. #ifdef DEBUG
  151. void dumpXpAttributes( Display *pdpy, XPContext pcontext );
  152. #endif /* DEBUG */
  153. void XpuWaitForPrintNotify( Display *pdpy, int xp_event_base, int detail );
  154.  
  155. /* Get list of printers */
  156. XPPrinterList XpuGetPrinterList( const char *printer, int *res_list_count );
  157. void XpuFreePrinterList( XPPrinterList list );
  158.  
  159. /* Set number of document copies */
  160. int XpuSetDocumentCopies( Display *pdpy, XPContext pcontext, long num_copies );
  161.  
  162. /* Get/Set/Query supported mediums (paper sizes) */
  163. XpuMediumSourceSizeList XpuGetMediumSourceSizeList( Display *pdpy, XPContext pcontext, int *numEntriesPtr );
  164. void XpuFreeMediumSourceSizeList( XpuMediumSourceSizeList list );
  165. int XpuSetDocMediumSourceSize( Display *pdpy, XPContext pcontext, XpuMediumSourceSizeRec *medium_spec );
  166. int XpuSetPageMediumSourceSize( Display *pdpy, XPContext pcontext, XpuMediumSourceSizeRec *medium_spec );
  167. XpuMediumSourceSizeRec *
  168. XpuFindMediumSourceSizeBySize( XpuMediumSourceSizeList mlist, int mlist_count,
  169.                                float page_width_mm, float page_height_mm, float tolerance );
  170. XpuMediumSourceSizeRec *
  171. XpuFindMediumSourceSizeByBounds( XpuMediumSourceSizeList mlist, int mlist_count, 
  172.                                  float m1, float m2, float m3, float m4, float tolerance );
  173. XpuMediumSourceSizeRec *
  174. XpuFindMediumSourceSizeByName( XpuMediumSourceSizeList mlist, int mlist_count, 
  175.                                const char *tray_name, const char *medium_name );
  176.  
  177. /* Get/Set resolution */
  178. XpuResolutionList XpuGetResolutionList( Display *pdpy, XPContext pcontext, int *numEntriesPtr );
  179. void XpuFreeResolutionList( XpuResolutionList list );
  180. Bool XpuGetResolution( Display *pdpy, XPContext pcontext, long *dpi );
  181. Bool XpuSetPageResolution( Display *pdpy, XPContext pcontext, XpuResolutionRec * );
  182. Bool XpuSetDocResolution( Display *pdpy, XPContext pcontext, XpuResolutionRec * );
  183. XpuResolutionRec *XpuFindResolution( XpuResolutionList list, int list_count, long min_dpi, long max_dpi );
  184.  
  185. /* Get/Set orientation */
  186. XpuOrientationList XpuGetOrientationList( Display *pdpy, XPContext pcontext, int *numEntriesPtr );
  187. void XpuFreeOrientationList( XpuOrientationList list );
  188. XpuOrientationRec *
  189. XpuFindOrientationByName( XpuOrientationList list, int list_count, const char *orientation );
  190. int XpuSetDocOrientation( Display *pdpy, XPContext pcontext, XpuOrientationRec *rec );
  191. int XpuSetPageOrientation( Display *pdpy, XPContext pcontext, XpuOrientationRec *rec );
  192.  
  193. /* Get/set plex modes */
  194. XpuPlexList XpuGetPlexList( Display *pdpy, XPContext pcontext, int *numEntriesPtr );
  195. void XpuFreePlexList( XpuPlexList list );
  196. XpuPlexRec *XpuFindPlexByName( XpuPlexList list, int list_count, const char *plex );
  197. int XpuSetDocPlex( Display *pdpy, XPContext pcontext, XpuPlexRec *rec );
  198. int XpuSetPagePlex( Display *pdpy, XPContext pcontext, XpuPlexRec *rec );
  199.  
  200. /* Start job to printer (spooler) or file */
  201. void XpuStartJobToSpooler(Display *pdpy);
  202. void *XpuStartJobToFile( Display *pdpy, XPContext pcontext, const char *filename );
  203. XPGetDocStatus XpuWaitForPrintFileChild( void *handle );
  204.  
  205. /* Get flags which indicate whether it is allowed to set/change a specific attribute */
  206. XpuSupportedFlags XpuGetSupportedJobAttributes(Display *pdpy, XPContext pcontext);
  207. XpuSupportedFlags XpuGetSupportedDocAttributes(Display *pdpy, XPContext pcontext);
  208. XpuSupportedFlags XpuGetSupportedPageAttributes(Display *pdpy, XPContext pcontext);
  209.  
  210. _XFUNCPROTOEND
  211.  
  212. #define XpuGetJobAttributes( pdpy, pcontext )     XpGetAttributes( (pdpy), (pcontext), XPJobAttr )
  213. #define XpuGetDocAttributes( pdpy, pcontext )     XpGetAttributes( (pdpy), (pcontext), XPDocAttr )
  214. #define XpuGetPageAttributes( pdpy, pcontext )    XpGetAttributes( (pdpy), (pcontext), XPPageAttr )
  215. #define XpuGetPrinterAttributes( pdpy, pcontext ) XpGetAttributes( (pdpy), (pcontext), XPPrinterAttr )
  216. #define XpuGetServerAttributes( pdpy, pcontext )  XpGetAttributes( (pdpy), (pcontext), XPServerAttr )
  217.  
  218. #endif /* !XPRINTUTIL_H */
  219. /* EOF. */
  220.